package com.gitee.wsl.compose.mvi.ui.textbutton

import androidx.compose.runtime.Composable
import androidx.compose.runtime.Stable
import com.gitee.wsl.compose.mvi.ui.button.ButtonPresenter
import com.gitee.wsl.compose.mvi.ui.button.ButtonType
import com.gitee.wsl.compose.mvi.component.base.Presenter
import com.gitee.wsl.compose.mvi.modifiable.presentable.PresentableModifier
import com.gitee.wsl.compose.mvi.ui.text.TextPresenter

data class TextButtonPresenter(
    override val modifier: PresentableModifier = PresentableModifier,
    val button: ButtonPresenter = ButtonPresenter.Default,
    val text: TextPresenter = TextPresenter.Default
) : Presenter<TextButtonPresenter>(modifier) {
    companion object {
        @Stable
        val Default = TextButtonPresenter()
    }

    override fun safeMerge(other: TextButtonPresenter) = TextButtonPresenter(
        modifier = modifier.merge(other.modifier),
        button = button.merge(other.button),
        text = text.merge(other.text)
    )

    @Composable
    override fun localized() = TextButtonPresenter(
        button = ButtonPresenter(type = ButtonType.TEXT)
    ).merge(this)
}